package com.leo.ibatis.demo.service.impl;

import java.util.List;

import com.leo.ibatis.demo.base.Service;
import com.leo.ibatis.demo.criteria.OrdersCriteria;
import com.leo.ibatis.demo.dao.OrdersDao;
import com.leo.ibatis.demo.domain.Orders;
import com.leo.ibatis.demo.service.OrdersService;

public class OrdersServiceImpl extends Service implements OrdersService {

	private OrdersDao ordersDao;

	public void setOrdersDao(OrdersDao ordersDao) {
		this.ordersDao = ordersDao;
	}

	public void insert(Orders orders) {
		ordersDao.insert(orders);
	}

	public int update(Orders orders) {
		int actualRowsAffected = 0;
		
		int orderid = orders.getOrderid();

		Orders _oldOrders = ordersDao.select(orderid);
		
		if (_oldOrders != null) {
			actualRowsAffected = ordersDao.update(orders);
		}
		
		return actualRowsAffected;
	}

	public int delete(int orderid) {
		int actualRowsAffected = 0;
		
		Orders _oldOrders = ordersDao.select(orderid);
		
		if (_oldOrders != null) {
			actualRowsAffected = ordersDao.delete(orderid);
		}
		
		return actualRowsAffected;
	}
	
	public Orders select(int orderid) {
		return ordersDao.select(orderid);
	}

	public List<Orders> list(OrdersCriteria ordersCriteria) {
		return ordersDao.list(ordersCriteria);
	}
	
	public List<Orders> listOnPage(OrdersCriteria ordersCriteria) {
		return ordersDao.listOnPage(ordersCriteria);
	}

}
